<?php

namespace app\index\controller;

use app\index\model\Photo;
use think\Controller;
use app\index\model\Product;

class Index extends Controller
{
    public function index()
    {
        //查询时尚达人商品信息
        $model = new Product();
        $shishang = $model->where('group_id', 1)->select();
        $zhineng = $model->where('group_id', 2)->select();
        $shenghuo = $model->where('group_id', 3)->select();
        $this->assign('shishang', $shishang);
        $this->assign('zhineng', $zhineng);
        $this->assign('shenghuoi', $shenghuo);
        return $this->fetch();
    }

    public function detail()
    {
        $id = input('id');
        //根据商品id查询商品详细信息
        $model = new Product();
        $product_info = $model->where('id', $id)->find();
        $this->assign('product_info', $product_info);
        //根据商品id 查询商品相册信息
        $photo = new Photo();
        $photos=$photo->where('product_id',$id)->select();

        $this->assign('photos',$photos);
        return $this->fetch();

    }

}
